<template lang='pug'>
  section
    van-nav-bar(
      title="店铺名片(长按发送给朋友)"
      left-arrow
      @click-left="$router.back()"
      )
    empty(title="获取名片失败 😊" v-show="!isLoading && !url")
    img(:src="url")
</template>

<script type='text/ecmascript-6'>
  import empty from '~/components/empty'

  export default {
    components: {
      empty,
    },
    data() {
      return {
        url: '',
        isLoading: true,
      }
    },
    computed: {
      user() { return this.$store.state.authUser || {} },
      userId() {
        if (!this.user ||!this.user.user) return ''
        return this.user.user.id
      },
    },
    async created() {
      this.isLoading = true
      const resp = await this.$post('/api/platform/qiniu/createCard', {userId: this.userId})
      this.isLoading = false
      if (resp && resp.data && resp.data.imageUrl) {
        this.url = resp.data.imageUrl
      } else {
        this.$toast('获取名片失败')
      }

    },
    methods: {
    }
  }
</script>

<style lang='stylus' rel='stylesheet/stylus' scoped>
 
img
  width 100%
</style>
